<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<link rel="stylesheet" href="../public/resiger.css">
<body>
   <div class="contain">
    <input type="text" name="" value="" placeholder="账号" class="Nickname"><br>
    <p>3~6个中文字符或数字或字母组合</p><br>
    <input type="password" name="" value="" placeholder="密码" class="pas"><br>
    <p>3~6个字符，区分大小写</p><br>
    <input type="password" name="" value="" placeholder="确认密码" class="psd"><br>
    <p>请再次填写密码</p><br>
    <button id="btn1">立即注册</button>
   </div>
    <img src="../public/img/big.jpg" alt="" id="big">
</body>
<script src="../public/jquery3.5.1.min.js"></script>

<script>
    $(".Nickname").blur(function(){
        console.log("1111");
        var Nickname=$(".Nickname").val();
        console.log(Nickname.length);
        var reg=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{2,5}$/;
        if(Nickname.length<3||Nickname.length>6){
            $('#btn1').attr('disabled',true);
           alert('3~6个中文字符或数字或字母组合');
        }else{
            $('#btn1').attr('disabled',false);
        }
          if(!reg.test(Nickname)){
            if(Nickname.length>=3&&Nickname.length<6){
                $('#btn1').attr('disabled',true);
                alert('3~6个中文字符或数字或字母组合');
            }else{
                $('#btn1').attr('disabled',false);
            }
        }
    })
    $('.pas').blur(function(){
        var pas= $('.pas').val();
        var reg= /^[0-9]{2,5}$/;
        if(pas.length>=3&&pas.length<6){
            if(!reg.test(pas)){
                $('#btn1').attr('disabled',true);
                alert("密码是3-6位数字");
            }else{
                $('#btn1').attr('disabled',false);
            }
        }

        if(pas.length>6||pas.length<3){
            $('#btn1').attr('disabled',true);
            alert("密码是3-6位数字");
        }else{
            $('#btn1').attr('disabled',false); 
        }
    })
    if($(".psd").val()!=$("pas").val()){
        $('#btn1').attr('disabled',true);
            alert("密码与确认密码不一样")
    }else{
        $('#btn1').attr('disabled',false); 
    }


    $("#btn1").click(function(){

        $.ajax({
            url:"http://192.168.1.7:8989/submit",
            method:"get",
            data:{
                Nickname:$(".Nickname").val(),
                pas:$(".pas").val(),
                // psd:$(".psd").val(),
            },
            success:function(res){
               
              if(res.ops.length>0){
                 console.log("1111");
               location.href='http://192.168.1.7:8989/login'
              }
               
            }
        })
    })
</script>
</html>